package streamApi;

import java.util.List;

/**
 * Stream的中间操作
 */
public class Demo02 {
    public static void main(String[] args) {
        List<PatientTemperatureVo> patientList = Demo01.getPatientList();
        //打印出所有数据中张三的信息
        patientList.stream().filter(patient -> patient.getName().equals("张三")).forEach(System.out::println);
        System.out.println();

        //截断流，使元素的个数不超过指定的个数
        patientList.stream().filter(patient -> patient.getName().equals("张三")).limit(3).forEach(System.out::println);
        System.out.println();

        //跳过元素
        patientList.stream().filter(patient -> patient.getName().equals("张三")).skip(2).forEach(System.out::println);
        System.out.println();

        //元素去重
        patientList.add(new PatientTemperatureVo("张三", "2020-01-24 12:25:26", 36.2));
        patientList.add(new PatientTemperatureVo("张三", "2020-01-24 12:25:26", 36.2));
        patientList.stream().distinct().filter(patient -> patient.getName().equals("张三")).forEach(System.out::println);
    }
}
